package th;

/**
 * @author Mark
 * @version 1.0
 * @date 2020/5/17 22:49
 * @description 多个线程同时执行
 */
public class MoreThread implements Runnable {

    private int num = 10;

    @Override
    public void run() {
        while (true) {
            if (num <= 0) {
                break;
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + ">>拿到第" + num + "票");
        }
    }


    public static void main(String[] args) {
        MoreThread moreThread = new MoreThread();
        new Thread(moreThread, "小胡").start();
        new Thread(moreThread, "校长").start();
        new Thread(moreThread, "小花").start();
    }
}